<?php
namespace Kuoqi;
use ReflectionClass;

/**
 * Class Invoke
 * @package Kuoqi
 * User kuoqi
 * Datetime 2022/3/1 11:21
 * Remark 功能待处理
 * todo-- invoke 功能待处理
 */
class Invoke extends ReflectionClass{
	public $query = null;
	protected $params = null;
	protected $invoke = null;	
	protected $methods = array();
	protected $instance = null;
	
	public function controlInstance($ins_name){
		return $this->instance = new $ins_name();
	}
	
	public function exportInstance(){
		return $this->instance;	
	}	
	
	public function joinQuery($query){
		$this->invoke = new ReflectionClass($query);
		$this->methods = $this->invoke->getMethods();	
		foreach($this->methods as $item){
			if($code = Format::invokeGet($item->name)){
				$this->instance->$code = $item->invokeArgs($query ,$item->getParameters());
			}
		}
	}
	
	public function joinParams($params){
		$this->params = $params;
		if(is_array($params)){
			foreach($this->params as $k=>$v){
				if(is_string($k)){
					$this->instance->$k = $v;
				}else{
					//todo--这个是列表数据的信息	
				}
			}
		}
	}
	
	//以数组的方式输出
	public function asArray(){
		return $this->params;	
	}
}